#!/bin/bash
if [ -e install.lock ]; then
    echo "========已安装======="
    exit
fi

# 查找 composer 的位置并设置为变量
COMPOSER=$(which composer)
if [ -z "$COMPOSER" ]; then
    echo "未找到 composer，请确保已安装 composer"
    exit 1
fi

if [ -f "vendor/autoload.php" ]; then
    echo "依赖已安装，跳过 composer install 步骤"
else
    # 使用 swoole-cli 执行 composer install 安装依赖
    ./swoole-cli $COMPOSER install --no-dev -vvv
fi

./swoole-cli bin/hyperf.php migrate
./swoole-cli bin/hyperf.php db:seed
./swoole-cli bin/hyperf.php  mine-extension:install  attractions/attraction-management
./swoole-cli bin/hyperf.php  mine-extension:install  attractions/commerce
./swoole-cli bin/hyperf.php  mine-extension:install  attractions/broadcast
./swoole-cli bin/hyperf.php  mine-extension:install  attractions/inspection
# ./swoole-cli bin/hyperf.php  mine-extension:install  attractions/hai-kang
./swoole-cli bin/hyperf.php  mine-extension:install  gq/video-monitoring
rm -rf runtime/container
echo 1 > install.lock